<!DOCTYPE HTML>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport"
		content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>官方公告</title>
	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
	<style>
		#app .header {
			width: 100%;
			height: 44px;
			line-height: 44px;
			text-align: center;
			background-color: #ffffff;
			font-size: 16px;
			position: fixed;
			top: 0;
			left: 0;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		#app .header img {
			width: 22px;
			height: 22px;
		}

		#app .header img:first-child {
			position: absolute;
			left: 15px;
		}

		#app .content {
			width: 100%;
			box-sizing: border-box;
			padding: 0 15px;
		}

		.content li {
			width: 100%;
			border-radius: 10px;
			overflow: hidden;
			background-color: #ffffff;
			box-sizing: border-box;
			margin-bottom: 15px;
		}

		.content li img {
			width: 100%;
			height: 150px;
			object-fit: cover;
		}

		.content li .title {
			font-size: 16px;
			line-height: 16px;
			margin: 15px 0 7.5px;
			color: #000;
			width: 280px;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
			padding: 0 15px;
			box-sizing: border-box;
		}

		.details {
			width: 100%;
			padding: 0 15px;
			box-sizing: border-box;
			overflow: hidden;
			text-overflow: ellipsis;
			display: -webkit-box;
			-webkit-line-clamp: 2;
			-webkit-box-orient: vertical;
			font-size: 13px;
			color: #666;
		}

		.times {
			width: 100%;
			padding: 0 15px;
			box-sizing: border-box;
			font-size: 12px;
			color: #999;
			margin-bottom: 15px;
			margin-top: 10px;
		}
	</style>
</head>

<body>
	<div id="app">
		<div class="header">
			<img src="../../image/icon_return.png" alt="" onclick="back()">官方公告
		</div>
		<div class="content">
			<!-- 跳转公众号链接 -->

		</div>
	</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript">
	let page = 1;
	let article = [];
	apiready = function () {
		resume("notice");

		$api.dom('.content').style.paddingTop = $api.fixStatusBar($api.dom('.header')) + 15 + 'px';
		getArticle(0);
		addEvent();
	}

	function getArticle(type) {
		$api.ajax({
			url: 'api/article/list',
			method: 'get',
			data: {
				values: {
					type: type,
					page: page,
				}
			},
			page: page,
			timeOutHtml: $api.dom('.content')
		}, function (ret) {
			article = article.concat(ret.data.list);
			ret.data.list.forEach(item => {
				let html = `<li class="list" onclick="open_details(` + item.id + `)">`
					+ (item.pic_url ? `<img src="` + $api.baseUrl + item.pic_url + `" alt="" onerror="showDefaultImg(this)">` : "")
					+ `<div class="title">` + item.title + `</div>
					<div class="details">`+ item.content + `</div>
					<div class="times">`+ getLocalTime(item.publish_time) + `</div>
				</li>`
				$api.append($api.dom(".content"), html);
			})
			api.refreshHeaderLoadDone();
			api.parseTapmode();
		});
	}

	function addEvent() {
		api.addEventListener({
			name: 'scrolltobottom',
			extra: {
				threshold: 1000,
			},
		}, function (ret, err) {
			page++;
			getArticle()
			api.removeEventListener({
				name: 'scrolltobottom'
			});
			setTimeout(function () {
				addEvent()
			}, 1000)
		});
	}


	function back() {
		api.closeWin({
		});
	}

	function open_details(id) {
		let url = article[article.findIndex(item => {
			return item.id == id
		})].url
		if (url) {
			api.openTabLayout({
				name: 'Url',
				url: '../Url.html',
				useWKWebView: true,
				bgColor: '#fff',
				pageParam: { url: url }
			});
		} else {
			api.openTabLayout({
				name: 'notice_details',
				url: './notice_details.html',
				useWKWebView: true,
				bgColor: '#fff',
				pageParam: {
					id: id
				}
			});
		}
	}
</script>

</html>
